﻿using System;
using System.Collections;
using MvcApplication1.Utility;
using RIMS.Lib.Manager;
using RIMS.Lib.Models;

namespace MvcApplication1.Actions.EmployeeActions
{
    public class Update : Common, IUpdate
    {
//        private readonly IEmployeeManager _employeeManager;
//        public Update(IEmployeeManager employeeManager)
//        {
//            _employeeManager = employeeManager;
//        }

        public Hashtable Execute(Employee employee, Guid oid)
        {
            Hashtable result = new Hashtable();
            result[Tools.IS_ERROR] = true;
            try
            {
                employee = new EmployeeManager().Update(employee);

                if (employee == null)
                {
                    result[Tools.MESSAGE] = "Data cannot updated";
                    return result;
                }

                result[Tools.ENTITY] = GetFlexiGrid(employee);
                result[Tools.MESSAGE] = "Update successfully";
                result[Tools.IS_ERROR] = false;
                return result;
            }
            catch (Exception ex)
            {
                return result;
            }
        }
    }
}